package com.dengqi.mymodule.activity.indicator;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import com.dengqi.mymodule.R;
import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;

import net.lucode.hackware.magicindicator.MagicIndicator;
import net.lucode.hackware.magicindicator.ViewPagerHelper;

import java.util.Arrays;
import java.util.List;

import androidx.viewpager.widget.ViewPager;


public class IndicatorActivity extends RxAppCompatActivity  {

    private static final String[] CHANNELS = new String[]{"CUPCAKE", "DONUT", "ECLAIR", "GINGERBREAD", "HONEYCOMB", "ICE_CREAM_SANDWICH", "JELLY_BEAN", "KITKAT", "LOLLIPOP", "M", "NOUGAT"};
    private List<String> mDataList = Arrays.asList(CHANNELS);
    private ViewPager mViewPager;
    private ExamplePagerAdapter mExamplePagerAdapter = new ExamplePagerAdapter(mDataList);


    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_indicator);

        mViewPager = (ViewPager) findViewById(R.id.view_pager);
        mViewPager.setAdapter(mExamplePagerAdapter);

        initMagicIndicator1();
        initMagicIndicator2();
        initMagicIndicator3();
        initMagicIndicator4();
        initMagicIndicator5();

    }

    public void initMagicIndicator1() {

        MagicIndicator magicIndicator = findViewById(R.id.magic_indicator1);
        magicIndicator.setBackgroundColor(Color.parseColor("#ff00ff"));
        MagicIndicatorTools magicTools = new MagicIndicatorTools(this);
        magicTools.setList(mDataList);//传泛型对象使用，builder里面要实现OnClipPagerTitleListener接口
        //  magicTools.setArrays(arrays);//传数组 不要传magicTools.setList ，builder里面接口传null,
        magicTools.setIndicatorStyle(MagicIndicatorTools.IndicatorStyle.NORMAL);
        magicTools.setAdjustMode(false);
        magicTools.setTextSize(14);
        magicTools.builder(magicIndicator);
        magicTools.setViewPager(mViewPager);
        ViewPagerHelper.bind(magicIndicator, mViewPager);
    }

    public void initMagicIndicator2() {

        MagicIndicator magicIndicator = findViewById(R.id.magic_indicator2);
        magicIndicator.setBackgroundColor(Color.parseColor("#ff0000"));
        MagicIndicatorTools magicTools = new MagicIndicatorTools(this);
        magicTools.setList(mDataList);//传泛型对象使用，builder里面要实现OnClipPagerTitleListener接口
        //  magicTools.setArrays(arrays);//传数组 不要传magicTools.setList ，builder里面接口传null,
        magicTools.setIndicatorStyle(MagicIndicatorTools.IndicatorStyle.LINE);
        magicTools.setAdjustMode(false);
        magicTools.setTextSize(14);
        magicTools.builder(magicIndicator);
        magicTools.setViewPager(mViewPager);
        ViewPagerHelper.bind(magicIndicator, mViewPager);
    }

    public void initMagicIndicator3() {

        MagicIndicator magicIndicator = findViewById(R.id.magic_indicator3);
        magicIndicator.setBackgroundColor(Color.parseColor("#00ffff"));
        MagicIndicatorTools magicTools = new MagicIndicatorTools(this);
        magicTools.setList(mDataList);//传泛型对象使用，builder里面要实现OnClipPagerTitleListener接口
        //  magicTools.setArrays(arrays);//传数组 不要传magicTools.setList ，builder里面接口传null,
        magicTools.setIndicatorStyle(MagicIndicatorTools.IndicatorStyle.BOX);
        magicTools.setAdjustMode(false);
        magicTools.setTextSize(14);
        magicTools.builder(magicIndicator);
        magicTools.setViewPager(mViewPager);
        ViewPagerHelper.bind(magicIndicator, mViewPager);
    }

    public void initMagicIndicator4() {

        MagicIndicator magicIndicator = findViewById(R.id.magic_indicator4);
        magicIndicator.setBackgroundColor(Color.parseColor("#0000ff"));
        MagicIndicatorTools magicTools = new MagicIndicatorTools(this);
        magicTools.setList(mDataList);//传泛型对象使用，builder里面要实现OnClipPagerTitleListener接口
        //  magicTools.setArrays(arrays);//传数组 不要传magicTools.setList ，builder里面接口传null,
        magicTools.setIndicatorStyle(MagicIndicatorTools.IndicatorStyle.DOT);
        magicTools.setAdjustMode(false);
        magicTools.setTextSize(14);
        magicTools.builder(magicIndicator);
        magicTools.setViewPager(mViewPager);
        ViewPagerHelper.bind(magicIndicator, mViewPager);
    }

    public void initMagicIndicator5() {

        MagicIndicator magicIndicator = findViewById(R.id.magic_indicator5);
        magicIndicator.setBackgroundColor(Color.parseColor("#00ff00"));
        MagicIndicatorTools magicTools = new MagicIndicatorTools(this);
        magicTools.setList(mDataList);//传泛型对象使用，builder里面要实现OnClipPagerTitleListener接口
        //  magicTools.setArrays(arrays);//传数组 不要传magicTools.setList ，builder里面接口传null,
        magicTools.setIndicatorStyle(MagicIndicatorTools.IndicatorStyle.BORDER);
        magicTools.setAdjustMode(false);
        magicTools.setTextSize(14);
        magicTools.builder(magicIndicator);
        magicTools.setViewPager(mViewPager);
        ViewPagerHelper.bind(magicIndicator, mViewPager);
    }
}
